﻿@{
    ViewBag.Title = "设备供应商";

}
@using FMS.UI.Extension;
@section headSecion{
    <script type="text/javascript">
        $(function() {
            $.globalHelper.datagridPara.init("/Factory/FactorySupplier/FactorySupplierIndex", [@Html.GetSonBtnJs()], [
                [
                    { field: 'supplier_Num', title: '供应商编号', width: 80 },
                    { field: 'supplier_Name', title: '供应商名称', width: 80 },
                    { field: 'supplier_Bank', title: '开户行', width: 80 },
                    { field: 'supplier_Account', title: '账户', width: 80 },
                    { field: 'supplier_TFN', title: '税号', width: 80 },
                    { field: 'supplier_TEL', title: '电话', width: 80 },
                    { field: 'supplier_Address', title: '地址', width: 80 }
                ]
            ]);
            $("#tbList").datagrid($.globalHelper.datagridPara.paras);
        });

          @if (Html.IsBtnExist("btnShow"))
          {
              <text>
        function btnShow() {
            var cond = $("#btnShowId").val();
            if (cond == null || cond === "") {
                $.msgBoxObj.showInfo("请输入搜索条件");
            } else {
                window.setTimeout(function () {
                    $.extend($("#tbList").datagrid("options"), {
                        url: '/Factory/FactorySupplier/FactorySupplierBtnSearch', //这里定义url    
                        queryParams: {
                            "searchCondition": cond
                        }
                    });
                    $("#tbList").datagrid("load");
                }, 100); //延迟100毫秒执行   
            }
            
        }
          </text>
          }

        @if (Html.IsBtnExist("add"))
        {
            <text>

        function add() {
            $.globalHelper.showCommonWindow("新增供应商", "/Factory/FactorySupplier/FactorySupplierAdd", 370, 325);
        }
        </text>
        }

        @if (Html.IsBtnExist("remove"))
        {
            <text>

        function remove() {
            ifSelected(function(selectedRowData) {
                window.top.ComSkipMsg(selectedRowData, "/Factory/FactorySupplier/FactorySupplierDel");
            });
        }
        </text>
        }

        @if (Html.IsBtnExist("setRolePer"))
        {
            <text>
        function setRolePer() //设置用户所属角色
        {
            ifSelected(function(perData) {
                $.globalHelper.showCommonWindow("设置【" + perData.supplier_Name + "】角色权限", "/Factory/FactorySupplier/FactorySupplierModify/" + perData.supplier_Id, 450, 560);
            });
        }
        </text>
        }

        @if (Html.IsBtnExist("modify"))
        {
            <text>
        function modify() {

            ifSelected(function(selectedRowData) { $.globalHelper.showCommonWindow("修改供应商", "/Factory/FactorySupplier/FactorySupplierModify/" + selectedRowData.supplier_Id, 370, 325) });
        }
        </text>
        }

        //统一判断是否有选中行 有则调用回掉函数(func) 并存入选中行的数据
        function ifSelected(func) {
            //获取选中行数据
            var selectedRowData = $("#tbList").datagrid("getSelected");
            if (selectedRowData) {
                if (func && func instanceof Function) {
                    func(selectedRowData);
                }


            } else {
                $.msgBoxObj.showInfo("请选中要操作的行");
            }
        }
    </script>
}

<table id="tbList" style="width:100%"></table>
